﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QuanLyNhaSach.DataAccessLayer
{
    
    public class HoaDonDAO
    {
        DataConnection dt_con = new DataConnection();
        public DataTable XemHoaDon()
        {
            return dt_con.Read("exec CTHD_Get");
        }
        public DataTable LayHoaDon(string a)
        {
            string cmd = "exec HOADON_Get '"+a+"'";
            return dt_con.Read(cmd);
        }
        public DataTable LayCTHD(string mahd)
        {
            string cmd = "exec CTHD_Get'" + mahd + "'";
            return dt_con.Read(cmd);
        }
        public void LuuChiTietHoaDon(string mahd, string masach, int soluong, int dongia)
        {
            string cmd = "exec CTHD_Insert '{0}','{1}',{2},{3}";
            dt_con.Write(String.Format(cmd,mahd,masach,soluong,dongia));
        }
        public DataTable LayTatCaHoaDon()
        {
            return dt_con.Read("exec HOADON_GetAll");
        }
        public DataTable LayHoaDonTheoThang(string a)
        {
            string cmd = "exec HOADON_GetforMonth '"+a+"'";
            return dt_con.Read(cmd);
        }
        public DataTable LayHoaDonNoTheoThang(string a)
        {
            string cmd = "exec HOADON_NotPayforMonth '" + a + "'";
            return dt_con.Read(cmd);
        }
        public void LuuHoaDon(string mahd, string makh, string a, string thanhtoan)
        {
            string cmd = "exec HOADON_Insert '{0}','{1}','{2}',{3}";
            dt_con.Write(String.Format(cmd, mahd, makh, a,thanhtoan));            
        }        
    }
}
